<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <!--    1.引入layui相关的css和js-->
    <!-- 引入 layui.css -->
    <link rel="stylesheet" href="//unpkg.com/layui@2.6.8/dist/css/layui.css"></link>
    <!-- 引入 layui.js -->
    <script src="//unpkg.com/layui@2.6.8/dist/layui.js"></script>
    <script src="js/jquery-3.6.0.min.js"></script>
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <form class="layui-form" action="" lay-filter="example">
<!--            输入框 可以设置type="hidden" 隐藏，外界看不见，但是可以提交数据 -->
            <input name="id" type="hidden" class="layui-input">
            <div class="layui-form-item">
                <label class="layui-form-label">选择楼层</label>
                <div class="layui-input-block">
                    <select name="floor" lay-filter="louceng">
                        <option value="" selected=""></option>
                        <option value="一楼" >一楼</option>
                        <option value="二楼">二楼</option>
                        <option value="三楼">三楼</option>
                        <option value="四楼">四楼</option>
                        <option value="五楼">五楼</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">选择房间</label>
                <div class="layui-input-block">
                    <select name="room" lay-filter="fangjian">
                        <option value="" selected=""></option>
                        <option value="第一学习室">第一学习室</option>
                        <option value="第二学习室" >第二学习室</option>
                        <option value="第三学习室">第三学习室</option>
                        <option value="第四学习室">第四学习室</option>
                        <option value="第五学习室">第五学习室</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">选择座位</label>
                <div class="layui-input-block">
                    <select name="seat" lay-filter="zuowei">
                        <option value="" selected=""></option>
                        <option value="1" >一号座位</option>
                        <option value="2" >二号座位</option>
                        <option value="3">三号座位</option>
                        <option value="4">四号座位</option>
                        <option value="5">五号座位</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">选择书籍id</label>
                <div class="layui-input-block">
                    <select name="bid" lay-filter="shuji">
                        <option value=""selected=""></option>
                        <option value="1" >1</option>
                        <option value="2" >2</option>
                        <option value="3">3</option>
                        <option value="4">4</option>
                        <option value="5">5</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="demo1">确认修改</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>
</div>

<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['form'], function () {
        var form = layui.form
            , layer = layui.layer;

        //监听提交
        form.on('submit(demo1)', function (data) {
            console.log(data.field);
            //ajax 调用接口 修改
            $.post("/api/libraryseat/update.do",data.field,function (res) {
                if (res.code==200){
                    layer.msg("修改成功");
                    //关闭当前页面
                    var iframeIndex = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(iframeIndex);
                } else{
                    layer.msg("修改失败")
                }
            });
            return false;
        });
        //获取要编辑的内容
        var json=localStorage.getItem("libraryseat");
        //表单初始赋值
        form.val('example',eval("("+json+")"));
    });
</script>
</body>
</html>